package com.yitiao.data_algorithms.leetcode.editor.cn;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

class TwoOutOfThree {
    // 2023-05-09 14:45:07
    public static void main(String[] args) {
        Solution solution = new TwoOutOfThree().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public List<Integer> twoOutOfThree(int[] nums1, int[] nums2, int[] nums3) {
            List<Integer> list = new ArrayList<>();
            Map<Integer, Integer> map1 = new HashMap<>();
            Map<Integer, Integer> map2 = new HashMap<>();
            for (int i : nums1) {
                map1.put(i, 1);
            }
            for (int i : nums2) {
                if (map1.containsKey(i)) {
                    if (!list.contains(i)) list.add(i);
                }
                map2.put(i, 1);
            }
            for (int i : nums3) {
                if (map1.containsKey(i) || map2.containsKey(i)) {
                    if (!list.contains(i)) list.add(i);
                }
            }
            return list;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}